<template>
  <div id="Common">
    <v-detail
      :detailData="inputData"
      :inputConfig="inputConfig"
      :rules="rules"
      ref="detail"
    ></v-detail>
  </div>
</template>

<script>
import detail from "commons/Detail";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "Common",
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object,
    },
  },
  data() {
    return {
      flag: false,
      whseidflag: false,
      rules: {
        storerkey: [
          {
            required: true,
            message: this.$inputPlease("config.carrier"),
            trigger: "blur",
          },
        ],
      },
    };
  },
  computed: {
    inputConfig() {
      return [
        [
          {
            type: "input",
            label: this.$t("config.carrier"),
            props: "storerkey",
            disabled: this.flag,
          },
          {
            type: "input",
            label: this.$t("config.company"),
            props: "company",
            disabled: this.whseidflag,
          },
          {
            type: "input",
            label: this.$t("common.desc"),
            props: "description",
            disabled: this.whseidflag,
          },
        ],
        [
          {
            type: "input",
            label: "Small Parcel SCAC",
            props: "sps_Scac",
            disabled: this.whseidflag,
          },
          {
            type: "input",
            label: "Carrier SCAC",
            props: "scac_Code",
            disabled: this.whseidflag,
          },
          {
            type: "input",
            label: this.$t("config.addIdentifier"),
            props: "vat",
            disabled: this.whseidflag,
          },
        ],
        [
          {
            type: "select",
            label: this.$t("config.currencyCode"),
            props: "currcode",
            options: this.getOptions("querycodeLkup/CURRCODE"),
            disabled: this.whseidflag,
          },
          {
            type: "checkbox",
            label: "Small Parcel System Carrier",
            props: "kship_Carrier",
            disabled: this.whseidflag,
          },
          {
            type: "checkbox",
            label: this.$t("config.trayExchangeFollow"),
            props: "containerexchangeflag",
            disabled: this.whseidflag,
          },
        ],
      ];
    },
  },
  methods: {},
  mounted() {
    if (this.$store.state.wms.toUpperCase().includes("WMWHSE")) {
      //仓库级
      this.flag = this.whseidflag = true;
    }
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      if (data.newFlag) {
        this.flag = false;
      } else {
        this.flag = true;
      }
    } else if (this.$store.state.newFlag) {
      this.flag = false;
    } else {
      this.flag = true;
    }
  },
  components: {
    "v-detail": detail,
  },
};
</script>

<style scoped></style>
